<template>
	<c-action-sheet ref="asIns" :btns="btns" @touch="handleSelect" title="选择小区" :isMaskClick="isMaskClick" hideCancel></c-action-sheet>
</template>

<script setup>
import { shallowRef, ref } from 'vue';
import { handleCommunityData } from "@/base/common-business.js";
import authCache from "@/uni-sdk/utils/authCache.js";
const props = defineProps({
	isLogin: Boolean,
	isMaskClick: Boolean,
});
const emits = defineEmits(["select"]);
const asIns = shallowRef();
const btns = ref([]);
function handleSelect({ item }){
	authCache.setCommunity(item);
	emits("select");
}
defineExpose({
	async open(){
		const data = await handleCommunityData();
		if(data) {
			if(data.length === 0) {
				getApp().globalData.toast("暂无社区数据，请联系管理员", true);
				return;
			}
			btns.value = data;
		}
		if(btns.value.length > 0) {
			asIns.value.open();
		}
	}
});
</script>

<style>

</style>